/**
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved.
 *
 * @file    sensor_interface_cfg_params.c
 * @brief   sensor dev interface config params:
 * one type interface config params must be choiced at global var "user_dev_attr"
 * @author  HiMobileCam NDK develop team
 * @date    2018-2-7
 */

#include "mpi_vi.h"
#include "mpi_isp.h"
#include "hi_sns_ctrl.h"
#include "sensor_comm.h"
#include "sensor_interface_cfg_params.h"
#include "../include/hi_mapi_sensorcfg_adapt.h"

static const HI_MAPI_MIPI_INTF_S g_stSensorMipiIntfCfg[] = {
    /* config 1080P@30fps */
    {
        .img_rect = {
            .x = 0,
            .y = 0,
            .width = 1920,
            .height = 1080
        },
        .stSnsSize = {
            .u32Width = 1920,
            .u32Height = 1080
        },
        .mipi_attr = {
            .input_data_type = DATA_TYPE_RAW_10BIT,
            .wdr_mode = HI_MIPI_WDR_MODE_NONE,
        },
    },
};

/* width and height must align with 4 bytes */
static const HI_MAPI_SENSOR_MODE_S g_stSensorMode[] = {
    /* SENSOR_MODE_1080p@30FPS  frameRate:[1.0-30] */
    {
        .s32Width = 1920,
        .s32Height = 1080,
        .u32SnsMode = 0,
        .enWdrMode = WDR_MODE_NONE,
        .f32SnsMaxFrameRate = 30.0f
    },
};

/* final interface here */
static HI_MAPI_COMBO_DEV_ATTR_S g_stSensorCfg = {
    /* config SENSOR */
    .pSensorObj = &stSnsGc2053Obj,
    .s32SensorType = GC2053,
    .input_mode = INPUT_MODE_MIPI,
    .data_rate = MIPI_DATA_RATE_X1,
    .sensor_i2c_addr = 0x6e,
    .stSensorInputAttr = {
        .enBayerFormat = BAYER_RGGB,
        .enSensorCommBusType = HI_SENSOR_COMMBUS_TYPE_I2C,
    },

    .stSensorMode = {
        .s32SensorModeCnt = sizeof(g_stSensorMode) / sizeof(HI_MAPI_SENSOR_MODE_S),
        .pSensorMode = (void*)g_stSensorMode,
        .pstIntf = (void*)g_stSensorMipiIntfCfg
    },

    .aLaneId = {
#if defined  CFG_LANE_DIVIDE_MODE_0
        /* mipi_dev0 */
        {
            {  0,  1,  -1,  -1}, /* 1080p@30FPS */
        },

        /* No mipi_dev1 */
        {
            {}, {}, {}, {}, {}, {},

        }

#endif
    },
};


HI_U32 SensorGc2053Init(void)
{
    return MAPI_SENSOR_Register((HI_MAPI_COMBO_DEV_ATTR_S*)&g_stSensorCfg);
}
